CFLAGS=-g -W
LIBS=-lX11 -lglut -lGL -lGLU -lm
CXX:=gcc

#编译所有子目录
SUBDIRS=`ls -d */ | grep -v 'bin' | grep -v 'lib' | grep -v 'include'`
#编译指定子目录
#SUBDIRS=dir1 dir2 dir3


SRCS = $(wildcard *.c)
BUILD = $(patsubst %.c, %, $(SRCS))
.c:.h
	$(CXX) -o $@ $< $(CFLAGS) $(LIBS)

define make_subdir
 @for subdir in $(SUBDIRS) ; do \
	  ( cd $$subdir && make $1) \
	   done;
 endef

all:
	 $(call make_subdir , all)

clean:
	 $(call make_subdir , clean) 
